package com.autcar.training.controller;

import com.autcar.training.entity.Insurance;
import com.autcar.training.service.InsuranceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Create by linjh on
 */
@RestController
@RequestMapping(value = "/Insurance")
public class InsuranceController {

    @Resource
    private InsuranceService insuranceService;


    //查询所有
    @GetMapping("/find")
    public List<Insurance> findAll(){
        return insuranceService.findAll();
    }

    //添加保险种类
    @PostMapping("/add")
    public String AddOne(@RequestBody Insurance insurance){
        insuranceService.addInsurance(insurance);
        return null;
    }

    //修改保险信息
    @PostMapping("/edit")
    public String EditOne(@RequestBody Insurance insurance){
        insuranceService.EditOne(insurance);
        return null;
    }

    //删除
    @GetMapping("/delete/{id}")
    public Integer delete(@PathVariable("id") Integer id){
        return insuranceService.deleteInsurance(id);
    }

    //根据订单号查询
    @GetMapping("/findByOne/{oid}")
    public List<Insurance> findByOne(@PathVariable("oid") Integer oid){
        return insuranceService.findById(oid);
    }
}
